package com.example.demohello.service.impl;

import com.example.demohello.entity.Course;
import com.example.demohello.mapper.CourseMapper;
import com.example.demohello.service.CourseService;
import com.example.demohello.vo.CourseRequestBo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CourseServiceImpl implements CourseService {


    @Autowired
    CourseMapper courseMapper;


    @Override

//    @CachePut(value = "course",key="#course.courseId")
    public Course addCourse(Course course) {
        Integer result =  courseMapper.addCourse(course);
        if(result>0)
            return course;
        else return null;
    }

    @Override
//    @CacheEvict(value = "course",key="#courseId")
    public Integer deleteCourse(Integer courseId) {
        Integer result =  courseMapper.deleteCourse(courseId);
        return result;
    }

    @Override
    public List<Course> selectCourse() {
        List<Course> courseList  =  courseMapper.selectCourse();
        return  courseList;
    }

    @Override
//    @Cacheable(value = "course",key="#courseId")
    public Course selectOneCourse(Integer courseId) {
         Course course  =  courseMapper.selectOneCourse(courseId);
         return course;

    }

    @Override
    public Integer updateCourse(Course course) {
        Integer result =  courseMapper.updateCourse(course);
        return result;
    }

    @Override
    public List<Course> selectForCourseList(CourseRequestBo requestBo) {
        List<Course> courseList  =  courseMapper.selectForCourseList( requestBo);
        return  courseList;
    }

    @Override
    public Integer selectCountCourse(CourseRequestBo requestBo) {
        return courseMapper.selectCountCourse(requestBo);
    }
}
